use std::ops::Add;

pub mod request;
pub mod response;
pub mod pod;

pub trait Object : Clone {
    fn group_version_kind(&self) -> GroupVersionKind;
    fn set_group_version_kind(&mut self,gvk:GroupVersionKind);
}

#[derive(Clone,Debug,Default)]
pub struct GroupVersionKind {
    pub group:String,
    pub version:String,
    pub kind:String,
}

impl GroupVersionKind {
    pub fn group_kind(&self) -> GroupVersion {
        GroupVersion{
            group: self.group.clone(),
            version: self.version.clone()
        }
    }

    pub fn string(&self) -> String {
        format!("{}/{},Kind={}",self.group,self.version,self.kind)
    }
}

#[derive(Clone,Debug,Default)]
pub struct GroupVersion {
    pub group:String,
    pub version:String,
}

impl GroupVersion {
    pub fn string(&self) -> String {
        let mut new_str = String::new();
        if self.group.len() > 0 {
            new_str = new_str.add(self.group.as_str());
            new_str.push('/');
        }

        new_str.add(self.version.as_str())
    }
}
